import { http } from '@/utils/axios/init'

// 相同前缀
// const prefix = '/ctms/Rest/project'

// 查询专业
export function majorLoadList(params) {
  return http.request({
    url: `/system/Rest/sysMajor/listByPage`,
    method: 'get',
    params
  })
}

// 新增项目
export function projectSave(params) {
  return http.request(
    {
      url: `/project/Rest/projectResearch/save`,
      method: 'post',
      params
    },
    {
      successMessageText: '项目添加成功'
    }
  )
}

// 查询项目的其他信息
export function projectOtherInfo(params) {
  return http.request({
    url: `/ctms/Rest/project/otherInfo`,
    method: 'get',
    params
  })
}

// 修改项目
export function projectUpdate(params) {
  return http.request(
    {
      url: `/project/Rest/projectResearch/update`,
      method: 'post',
      params
    },
    {
      successMessageText: '项目修改成功'
    }
  )
}

// 查询项目中心
export function getUserGrantProjectlist(data) {
  return http.request({
    url: `/ctms/Rest/project/getUserGrantProjectlist`,
    method: 'get',
    params: data
  })
}

// 查询项目成员
export function getOrgProjectUserList(params) {
  return http.request({
    url: `/system/Rest/user/getOrgProjectUserList`,
    method: 'get',
    params
  })
}

// 添加根据手机号码精确查询用户列表
export function userPreciseQuery(mobile) {
  return http.request({
    url: `/system/Rest/user/userPreciseQuery`,
    method: 'get',
    params: { mobile }
  })
}

// 添加项目成员
export function saveOrgProjectUser(params) {
  return http.request({
    url: `/system/Rest/user/saveOrgProjectUser`,
    method: 'post',
    params
  })
}

// 修改项目成员
export function updateOrgProjectUser(params) {
  return http.request({
    url: `/system/Rest/user/updateOrgProjectUser`,
    method: 'post',
    params
  })
}

// 获取项目统计信息
export function getProjectReport(params) {
  return http.request({
    url: `/ctms/Rest/projectHome/getProjectReport`,
    method: 'get',
    params
  })
}
// 获取里程碑任务列表
export function getMilestoneTaskList(params) {
  return http.request({
    url: `/ctms/Rest/projectHome/getMilestoneTaskList`,
    method: 'get',
    params
  })
}

// 修改试验状态
export function projectTrialUpdateStatus(params) {
  return http.request(
    {
      url: `/project/Rest/projectTrial/updateStatus`,
      method: 'post',
      params
    },
    {
      successMessageText: '修改成功'
    }
  )
}

// 修改项目状态
export function projectUpdateStatus(params) {
  return http.request(
    {
      url: `/project/Rest/projectResearch/updateStatus`,
      method: 'post',
      params
    },
    {
      successMessageText: '修改成功'
    }
  )
}

// 项目中心文档批量批量下载
export function projectFilebatchDowload(params) {
  return http.request(
    {
      url: `/doc/Rest/doc/file/batchDowload`,
      responseType: 'blob',
      method: 'post',
      params
    },
    {
      isReturnNativeResponse: true
    }
  )
}

// 导出项目数据
export function exportProjectData(params) {
  return http.request(
    {
      url: `/ctms/Rest/project/export`,
      responseType: 'blob',
      method: 'get',
      params
    },
    {
      isReturnNativeResponse: true,
      isTransformResponse: false
    }
  )
}

// 查询导出配置
export function getExportConfig() {
  return http.request({
    url: `/ctms/Rest/projectExportField/getExportConfig`,
    method: 'get'
  })
}

// 修改项目成员-new
export function updateOrgProjectUserAuth(params) {
  return http.request({
    url: `/system/Rest/user/updateOrgProjectUserAuth`,
    method: 'post',
    params
  })
}
// 获取字段的更新日志
export function getUpdateFieldList(params) {
  return http.request({
    url: `/project/Rest/projectFieldLog/getUpdateFieldList`,
    method: 'get',
    params
  })
}

// 获取字段的更新日志
export function getProjectFieldLog(params) {
  return http.request({
    url: `/project/Rest/projectFieldLog/list`,
    method: 'get',
    params
  })
}

// 预览
export function previewExperience(params) {
  return http.request(
    {
      url: `/system/Rest/user/exportExperiencePdf`,
      method: 'get',
      responseType: 'blob',
      headers: {
        'yootrial-account': 0,
        'yootrial-app': 0,
        'yootrial-signature': 0,
        'yootrial-timestamp': Date.now()
      },
      params
    },
    {
      isReturnNativeResponse: true
    }
  )
}
